package com.mall.b2c.controller;

import com.mall.b2c.service.IntergralLogService;
import com.mall.b2c.service.IntergralService;
import com.mall.b2c.util.JsonDataGridHelper;
import com.mall.common.bean.Pager;
import com.mall.common.bean.SearchFilter;
import com.mall.common.controller.BaseController;
import com.mall.common.web.Servlets;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * Created by chen on 16/12/15.
 */
@Controller
@RequestMapping("/admin/b2c/intergral")
public class IntergralController  extends BaseController {
    @Resource
    IntergralService intergralService;
    /**
     * 跳转到列表页面
     */
    @RequestMapping(value="/list", method= RequestMethod.GET)
    public String list(Model model){
        return "/admin/b2c/intergral/list";
    }
    /**
     * 获取列表信息
     */
    @RequestMapping(value="/queryData", method=RequestMethod.POST)
    @ResponseBody
    public Pager queryData(Pager pager, HttpServletRequest request){
        Map<String, Object> filterParams = Servlets.getParametersStartingWith(request);
        List<SearchFilter> filters = SearchFilter.parse(filterParams);
        pager = intergralService.findPage(pager, filters);
        return JsonDataGridHelper.createJSONData(pager);
    }
}
